<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:include="~{common/header :: commonHead}">
    <title>限制详情</title>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="row form-body form-horizontal m-t" id="form1" method="post" th:action="${'/integral_rule/edit'}" onsubmit="return submitForm()">
                        <input name="id" th:value="${editable?.id}" style="display: none">
                        <div class="col-md-12 droppable sortable ui-droppable ui-sortable">
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label">积分规则内容：</label>
                                <div class="col-sm-6">
                                    <input type="text" name="ruleContent" class="form-control" th:value="${editable?.ruleContent }" placeholder="积分规则内容">
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label">积分翻倍（会员等级）：</label>
                                <div class="col-sm-6">
                                    <div class="radio radio-info radio-inline">
                                        <input type="radio" id="inlineRadio1" name="memberLevelDouble" value="1" th:checked="${editable?.memberLevelDouble == true}">
                                        <label for="inlineRadio1">是 </label>
                                    </div>
                                    <div class="radio radio-danger radio-inline">
                                        <input type="radio" id="inlineRadio2" name="memberLevelDouble" value="0" th:checked="${editable?.memberLevelDouble == false}">
                                        <label for="inlineRadio2">否 </label>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label">积分翻倍（会员生日）：</label>
                                <div class="col-sm-6">
                                    <div class="radio radio-info radio-inline">
                                        <input type="radio" id="inlineRadio3" name="memberBirthDayDouble" value="1" th:checked="${editable?.memberBirthDayDouble == true}">
                                        <label for="inlineRadio3">是 </label>
                                    </div>
                                    <div class="radio radio-danger radio-inline">
                                        <input type="radio" id="inlineRadio4" name="memberBirthDayDouble" value="0" th:checked="${editable?.memberBirthDayDouble == false}">
                                        <label for="inlineRadio4">否 </label>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group draggable ui-draggable dropped" id="birth_day_num" th:style="${'position: static; display:' + (editable?.memberBirthDayDouble == true ? 'block' : 'none')}" >
                                <label class="col-sm-3 control-label">会员生日积分倍数：</label>
                                <div class="col-sm-6">
                                    <input type="text" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" name="birthDayDouble" required="required" class="form-control" th:value="${editable?.birthDayDouble }" placeholder="会员生日积分倍数(注：此处只可填 ' >= 0' 的整数)">
                                </div>
                            </div>

                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label">积分翻倍（时间段）：</label>
                                <div class="col-sm-6">
                                    <div class="radio radio-info radio-inline">
                                        <input type="radio"  id="inlineRadio5" name="timeDouble" value="1" th:checked="${editable?.timeDouble == true}">
                                        <label for="inlineRadio5">是 </label>
                                    </div>
                                    <div class="radio radio-danger radio-inline">
                                        <input type="radio"  id="inlineRadio6" name="timeDouble" value="0" th:checked="${editable?.timeDouble == false}">
                                        <label for="inlineRadio6">否 </label>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group draggable ui-draggable dropped"  id="total-input-use" th:style="${'position: static; display:' + (editable?.timeDouble == true ? 'block' : 'none')}">
                                <label class="col-sm-3 control-label">有效期：</label>
                                <div class="col-sm-3">
                                    <div class="input-group date">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" class="form-control" id="start_time" placeholder="开始时间" th:value="${editable?.startTime}" name="startTime" >
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="input-group date">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" class="form-control" id="end_time" placeholder="结束时间" th:value="${editable?.endTime}" name="endTime">
                                    </div>
                                </div>
                            </div>

                            <div class="form-group draggable ui-draggable dropped" th:style="${'position: static; display:' + (editable?.timeDouble == true ? 'block' : 'none')}">
                                <label class="col-sm-3 control-label">时间段积分翻倍系数：</label>
                                <div class="col-sm-6">
                                    <input type="text" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" name="timeDoubleNum" class="form-control" th:value="${editable?.timeDoubleNum }" placeholder="时间段积分翻倍系数(注：此处只可填 ' >= 0' 的整数)">
                                </div>
                            </div>

                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label">积分翻倍（业态）：</label>
                                <div class="col-sm-6">
                                    <div class="radio radio-info radio-inline">
                                        <input type="radio"  id="inlineRadio7" name="storeCommercial" value="1" th:checked="${editable?.storeCommercial == true}">
                                        <label for="inlineRadio7">是 </label>
                                    </div>
                                    <div class="radio radio-danger radio-inline">
                                        <input type="radio"  id="inlineRadio8" name="storeCommercial" value="0" th:checked="${editable?.storeCommercial == false}">
                                        <label for="inlineRadio8">否 </label>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group draggable ui-draggable dropped" id="store_c" style="position: static;" th:style="${'position: static; display:' + (editable?.storeCommercial == true ? 'block' : 'none')}">
                                <label class="col-sm-3 control-label">选择积分业态：</label>
                                <div class="col-sm-6 cates" >
                                    <label  class="checkbox-inline" th:each="item : ${commercials}" th:with="checked=${#lists.contains(editable.commercialIds,item.id)}">
                                        <input  th:update="${item.id}"  type="checkbox" th:checked="${checked}" name="commercialIds" th:value="${item.id}"><span th:text="${item.name}"></span>
                                    </label>
                                </div>
                            </div>

                            <div class="form-group draggable ui-draggable dropped" id="double_num" th:style="${'position: static; display:' + (editable?.storeCommercial == true ? 'block' : 'none')}">
                                <label class="col-sm-3 control-label">业态积分翻倍系数：</label>
                                <div class="col-sm-6">
                                    <input type="text" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" name="doubleNum" class="form-control" th:value="${editable?.doubleNum}" placeholder="业态积分翻倍系数(注：此处只可填 ' >= 0' 的整数)">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>

                            <div class="form-group draggable ui-draggable">
                                <div class="col-sm-12 col-sm-offset-3">
                                    <button class="btn btn-primary"  type="submit" >保存内容</button>
                                </div>
                            </div>

                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/js/plugins/chosen/chosen.jquery.js"></script>
<script>

    function submitForm(){

        var flag = false;

        $(".checkbox-inline").each(function(){
           var checked = $(this).children("input[type='checkbox']").prop("checked");
           console.log(checked);
           if(checked){

               flag = true;

               return false;
           }
        });
        if(flag){
            return true;
        }else{
            alert("请选择积分业态");
            return false;
        }

    }


    $("#start_time").datetimepicker({
        weekStart: 0, //一周从哪一天开始
        todayBtn:  1, //
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1
    });
    $("#end_time").datetimepicker({
        weekStart: 0, //一周从哪一天开始
        todayBtn:  1, //
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1
    });

    $("input[name=memberBirthDayDouble]").change(function () {
        let selection = $(this).val();
        if (selection == 1) {
            $("#birth_day_num").css('display','block');
        }
        if (selection == ''||selection == 0) {
            $("#birth_day_num").css('display','none');
        }
    })

    $("input[name=timeDouble]").change(function () {
        let selection = $(this).val();
        if (selection == 1) {
            $("#total-input-use").css('display','block');
            $("#time_double_num").css('display','block');
        }
        if (selection == ''||selection == 0) {
            $("#total-input-use").css('display','none');
            $("#time_double_num").css('display','none');
        }
    })

    $("input[name=storeCommercial]").change(function () {
        let selection = $(this).val();
        if (selection == 1) {
            $("#store_c").css('display','block');
            $("#double_num").css('display','block');
        }
        if (selection == ''||selection == 0) {
            $("#store_c").css('display','none');
            $("#double_num").css('display','none');
        }
    })
    $("input[name=commercialIds]").change(function () {
        console.log($(this).attr('update')==undefined)
        if($("#inlineRadio7").is(":checked")){


        }
    })
</script>
</body>
</html>